<template>
	<view class="add">
		<u--form
		:model="info"
		>
		<u-form-item
		label="学历"
		prop="info.education"
	    labelWidth='80'
		ref="item1"
	
		>
		<u--input
		v-model="info.education"
		placeholder="请填写学历"
		border="none"
		></u--input>
		</u-form-item>
		
		<u-form-item
		label="住址"
		labelWidth='80'
		prop="info.address"
	
		ref="item1"
		>
		<u--input
		v-model="info.address"
		placeholder="请填写住址"
		border="none"
		></u--input>
		</u-form-item>
		
		<u-form-item
		label="期望薪资"
		labelWidth='80'
		prop="info.money"
		
		ref="item1"
		>
		<u--input
		v-model="info.money"
		placeholder="请填写期望薪资"
		border="none"
		></u--input>
		</u-form-item>
		
		<u-form-item
		label="工作经历"
		labelWidth='80'
		prop="info.experience"
		
		ref="item1"
		>
		<u--input
		v-model="info.experience"
		placeholder="请填写工作经历"
		border="none"
		></u--input>
		</u-form-item>
		
		<u-form-item
		label="个人简介"
		labelWidth='80'
		prop="info.individualResume"
		
		ref="item1"
		>
		<u--textarea v-model="info.individualResume" placeholder="请输入内容" ></u--textarea>
		
		</u-form-item>
		
		<view class="but">
		<up-button type="primary" text="提交" @click="submit"></up-button>
		</view>
		
		
		</u--form>

	</view>
</template>

<script setup>
import { getCurrentInstance, onMounted, reactive, ref } from 'vue';
import {getresume} from '../../../api/jobApi.js'

const info =ref({
	money:'',               //薪资
	education:'',           //学历
	address:'',            //地址
	experience:'',         //工作经验
	individualResume:''   //个人简历
})

const id =ref()       //id
// const uinfo =ref(null)
  
// const rules =reactive({  
//   'info.education':[  
//     { required: true,message: '学历不能为空',trigger: ['blur','change']}  
//   ],
//    'info.address':[
// 	  { required: true,message: '地址不能为空',} 
// 	], 
// 	'info.money':[
// 	  {  
// 	    required: true,  
// 	    message: '薪资不能为空',  
	   
// 	  },  
// 	],
// 	'info.experience':[
// 	  {  
// 	    required: true,  
// 	    message: '工作经验不能为空',  
	   
// 	  },  
// 	],
// 	'info.individualResume':[
// 	  {  
// 	    required: true,  
// 	    message: '个人简介不能为空',  
	   
// 	  },  
// 	],
// });

//点击提交
const submit=async()=>{

	//判断输入框内容不能为空
	if(info.value.money=='' || info.value.education==''|| info.value.address=='' || info.value.experience=='' || info.value.individualResume==''){
		uni.showToast({
				title:'内容不能为空',
				duration: 1000,
				icon:'error'
			})
	return;
	}
	
	let res = await getresume({
		header:{
			'Authorization':uni.getStorageSync('token')
		},
		data:{
		money:info.value.money,
		education:info.value.education,
		address:info.value.address,
		experience:info.value.experience,
		individualResume:info.value.individualResume,
		}
	})
	console.log(res);
	if(res.code==500){
		uni.showToast({
			title:res.msg,
			duration: 1000,
			icon:'error'
			
		})
	}else if(res.code==200){
		uni.showToast({
			title:'添加成功',
			duration: 1000,
		})
	}else{
		uni.showToast({
			title:'添加成功',
			duration: 1000,
		})
	}

}
onMounted(()=>{
	id.value =getCurrentInstance().attrs.id
})

</script>
<style lang="scss">
::v-deep uni-page-wrapper{
background-color: rgb(247, 248, 250);	
}
.add{
	height: 100%;
	background-color: rgb(247, 248, 250);
	padding: 0px 10px;
	overflow: hidden;

	.u-form-item{
	background-color:#fff;
	padding: 0px 10px;	
	margin: 5px;
	border-radius: 8px;
	}
	
	.but{
		margin: 20px 0px;
	}
	
	
}

</style>
